﻿<html DIR="LTR" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
  <head>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8" />
    <META NAME="save" CONTENT="history" />
    <title>Readme_DB3D</title>
    
 <Style TYPE="text/css">

body
{
    background: #FFFFFF;
    color: #000000;
    font-family:    Verdana;
    font-size: medium;
    font-style: normal;
    font-weight: normal;
    margin-top: 0;
    margin-bottom:  0;
    margin-left:    0;
    margin-right:   0;
    width:  100%;
}

div.#mainSection
{
    font-size: 70%;
    width: 100%;
    padding-left:    10;
    margin-right: 10;
}

div.#mainBody
{
    font-size: 90%;
    margin-top: 10;
    padding-bottom: 20;
}

div.#header
{
    background-color: #D2D2D2;
    padding-top:    0;
    padding-bottom: 0;
    padding-left:   10;
    padding-right:  0;
    width:          100%;
}

div.#header table
{
    border-bottom-color: #C8CDDE;
    border-bottom-style: solid;
    border-bottom-width: 1;
    width:  100%;
}

span.#runningHeaderText
{
    color: #003399;
    font-size: 90%;
}

span.#nsrTitle
{
/*    color: #003399;*/
    font-size: 120%;
    font-weight: 600;
}

div.#header table td
{
    color: #000000;
    font-size: 70%;
    margin-top: 0;
    margin-bottom:  0;
    padding-right: 20;
}

div.#header table tr.#headerTableRow3 td
{
    padding-bottom: 2;
    padding-top: 5;
}

div.#header table.#bottomTable
{
    border-top-color: #FFFFFF;
    border-top-style: solid;
    border-top-width: 1;
    text-align: left;
}

div.#footer
{
    font-size: 90%;
    margin-top: 0;
    margin-bottom:  0;
    margin-left:    -5;
    margin-right:   0;
    padding-top:    2;
    padding-bottom: 2;
    padding-left:   0;
    padding-right:  0;
    width:  100%;
}

hr.#footerHR
{
    border-bottom-color: #EEEEFF;
    border-bottom-style: solid;
    border-bottom-width: 1;
    border-top-color: C8CDDE;
    border-top-style: solid;
    border-top-width: 1;
    height: 3;
    color: #D2D2D2;
}

div.section
{
    padding-top:    2;
    padding-bottom: 2;
    padding-right:  15;
    width:  100%;
}

.heading
{
    color:          #000000;
    font-weight:    bold;
    margin-top:     18;
    margin-bottom:  8;
}

h1.heading
{
    color: #000000;
    font-size:  150%;
}

.subHeading
{
    color:          #000000;
    font-weight:    bold;
    font-size:      150%;
    margin-bottom:  4;
}

h2.subHeading
{
    color:          #000000;
    font-weight:    bold;
    font-size:      130%;
}
h3.subHeading
{
    color:  #000000;
    font-size: 125%;
    font-weight: bold;
}

h4.subHeading
{
    color: #000000;
    font-size: 110%;
    font-weight: bold;
}

h4.procedureHeading
{
    color: #000080;
    font-size: 110%;
    font-weight: bold;
}

h5.subHeading
{
    color: #000000;
    font-size: 100%;
    font-weight: bold;
}

img
{
    padding-bottom: 10;
}

img.toggle
{
    border: 0;
    margin-right: 5;
    padding-bottom: 10;
}

img.copyCodeImage
{
    border: 0;
    margin: 1;
    margin-right: 3;
    padding-bottom: 10;
}

img.downloadCodeImage
{
    border: 0;
    margin-right: 3;
    padding-bottom: 10;
}

img.viewCodeImage
{
    border: 0;
    margin-right: 3;
    padding-bottom: 10;
}

img.note
{
    border: 0;
    margin-right: 3;
    padding-bottom: 10;
}

img.#membersOptionsFilterImage
{
    border: 0;
    margin-left: 10;
    vertical-align: middle;
    padding-bottom: 10;
}

img.#toggleAllImage
{
    margin-left: 4;
    vertical-align: middle;
    padding-bottom: 10;
}

div.#mainSection table
{
    border: 0;
    font-size: 100%;
    width:  100%;
    margin-top: 5px;
    margin-bottom: 15px;
}

div.#mainSection table tr
{
    vertical-align: top;
}

div.#mainSection table th
{
    text-align: left;
    background: #D8D8D8;
    border-bottom-color: #D8D8D8;
    border-bottom-style: solid;
    border-bottom-width: 1;
    color: #000000;
    padding-left: 5;
    padding-right: 5;
}

div.#mainSection table td
{
    background: #F2F2F2;
    border-top-color: #D8D8D8;
    border-top-style: solid;
    border-top-width: 1;
    padding-left: 5;
    padding-right: 5;
}

div.#mainSection table td.imageCell
{
    white-space: nowrap;
}

div.code
{
	width: 98%;
}

div.code table
{
    border: 0;
    font-size: 95%;
    margin-bottom: 5;
    width: 100%
}

div.code table th
{   
    text-align: left;
    background: #D8D8D8;
    border-bottom-color: #D8D8D8;
    border-bottom-style: solid;
    border-bottom-width: 1;
    color: #000000;
    font-weight: bold;
    padding-left: 5;
    padding-right: 5;
}

div.code table td
{
    background: #CCCCCC;
    border-top-color: #D8D8D8;
    border-top-style: solid;
    border-top-width: 1;
    padding-left: 5;
    padding-right: 5;
    padding-top: 5;
}

div.alert
{
	margin-left: 10;
	width: 98%;
}

div.alert table
{
    border: 1;
    font-size: 100%;
    width:  100%;
    border: solid 1 #DEDFEF;
}

div.alert table th
{
    text-align: left;
    background: #D8D8D8;
    border-bottom-width: 0;
    color: #000000;
    padding-left: 5;
    padding-right: 5;
    border: solid 1 #DEDFEF;
}

div.alert table td
{
    background: #FFFFFF;
    border-top-color: #D8D8D8;
    border-top-style: solid;
    border-top-width: 1;
    padding-left: 5;
    padding-right: 5;
    border: solid 1 #DEDFEF;
}

span.copyCode
{
    color: #0000ff;
    font-size: 90%;
    font-weight: normal;
    cursor: hand;
    float: right;
    display: inline;
    text-align: right;
}

.downloadCode
{
    color: #0000ff;
    font-size: 90%;
    font-weight: normal;
    cursor: hand;
}

.viewCode
{
    color: #0000ff;
    font-size: 90%;
    font-weight: normal;
    cursor: hand;
}

div.code pre
{
    font-family:    Monospace, Courier New, Courier;
    font-size: 105%;
    color:  #000000;
}

code
{
    font-family:    Monospace, Courier New, Courier;
    font-size: 105%;
    color:  #000000;
}

dl
{
    margin-top: 0;
    padding-left:   1;
}

dd
{
    margin-bottom:  0;
    margin-left:    0;
    padding-left:   20;
}

dd p
{
    margin-top: 5;
}

ul
{
    margin-left: 17;
    list-style-type: disc;
}

ul ul
{
    margin-bottom: 4;
    margin-left: 17;
    margin-top: 3;
    list-style-type: disc;
}

ol
{
    margin-left: 24;
    list-style-type: decimal;
}

ol ol
{
    margin-left: 24;
    margin-top: 3;
    list-style-type: lower-alpha;
}

li
{
    margin-top: 0;
    margin-bottom: 0;
    padding-bottom: 0;
    padding-top: 0;
    margin-left: 5;
}

p
{
    margin-bottom: 15;
}

.tip
{
    color:  #0000FF;
    font-style: italic;
    cursor:hand;
    text-decoration:underline;
}

.math
{
    font-family: Times New Roman;
    font-size: 125%
}
.sourceCodeList
{
    font-family: Verdana;
    font-size: 90%; 
}

pre.viewCode
{
    width: 100%;
    overflow: auto;
}

li:hover table, li.over table
{
    background-color: #C0C0C0;
}

li:hover ul, li.over ul
{ 
    background-color: #d2d2d2;
    border: 1px solid #000;
    display: block;
}

</style>
  </head>
  <body>
    <!--Topic built:2/12/2007-->

    <div id="header">
      <table width="100%" id="topTable">
        <tr>
          <td align="left">
            <span id="nsrTitle">Readme_DB3D</span>
          </td>
          <td align="right">
            <span id="headfb" class="feedbackhead">
            </span>
          </td>
        </tr>
        <tr id="headerTableRow3">
          <td />
          <td align="right">
          </td>
        </tr>
      </table>
      </div>
    <div id="mainSection">
      <div id="mainBody">

        <font color="DarkGray">[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.] </font><p /> 
        <span id="changeHistory">
        </span>
    <p>
      This sample works only with SQL Server 2005 and SQL Server "Katmai". It will not work with any version of SQL Server earlier than SQL Server 2005.
    </p>
    <p>DB3D is an example application that stores, visualizes and manipulates tri-dimensional wireframe models by using SQL Server and .NET Framework.</p>
    <p>The default installation directory is C:\Program Files\Microsoft SQL Server\100\Samples\Integrated Samples\DB3D</p>
  <h1 class="heading">Scenario</h1><div id="sectionSection0" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">The DB3D application illustrates how to take advantage of various SQL Server 2005 features to handle several common application needs.</p>
      <p xmlns="">The application can load tri-dimensional wireframe models from a file or from a database. It can also upload new wireframe models into a database by using various techniques that show different performance characteristics. </p>
      <p xmlns="">Wireframe models are represented by using triangles in space. Triangles are directly stored in the database as user-defined types and also used by the client application to manipulate the rendered wireframes.</p>
      <p xmlns="">Once in the database, wireframe models can be manipulated interactively on the client, or through Transact-SQL in the server by using the SQL-CLR methods included in the sample library. The application also supports reporting on the wireframes that are contained in the database, for which it uses custom aggregates to perform computation close to the data and avoids data-shipping costs.</p>
    </content></div><h1 class="heading">Languages</h1><div id="sectionSection1" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">
        Transact-SQL and Visual C#.</p>
    </content></div><h1 class="heading">Features</h1><div id="sectionSection2" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">The DB3D sample uses the new features of SQL Server as shown in the following table:</p>
      <h3 class="subHeading" xmlns=""></h3><table width="100%" cellspacing="0" cellpadding="0" border="1" style="background-color: #CCCCCC;" xmlns=""><tr>
            <th>
              Application Area
            </th>
            <th>
              Features
            </th>
          </tr><tr>
          <td>
            <p>Representing wireframe model data</p>
          </td>
          <td>
            <p>Use of SQL Server user-defined types to appropriately represent pieces of information of the problem domain of the application. In the case of DB3D, two user-defined types are defined, "Triangle" and "Point3D". The example shows how to use the types both from within SQL Server and from a client application through ADO.NET 2.0.</p>
          </td>
        </tr><tr>
          <td>
            <p>Manipulating wireframe models</p>
          </td>
          <td>
            <p>The "Triangle" and "Point3D" user-defined types include, in addition to their persistent state, a rich set of methods to manipulate them (for example to rotate a triangle in space). Those methods can be used both from the client and from within SQL Server itself to interact and change models.</p>
          </td>
        </tr><tr>
          <td>
            <p>Computing summary information for wireframe models</p>
          </td>
          <td>
            <p>Use of SQL Server user-defined aggregates to perform processing close to the data (in the database) using custom algorithms. The sample can compute the surface of a given model by using a custom aggregate. This lets the system perform the computation in an efficient environment (CLR) without having to ship the data to another tier.</p>
          </td>
        </tr><tr>
          <td>
            <p>Uploading wireframe data quickly into the database</p>
          </td>
          <td>
            <p>The application includes two strategies for uploading data: one based on regular INSERT statements and the other uses the new SqlBulkCopy class included in ADO.NET 2.0. Both are available so their performance characteristics can be compared.</p>
          </td>
        </tr><tr>
          <td>
            <p>Connect-to-database dialog box</p>
          </td>
          <td>
            <p>The new SqlConnectionStringBuilder class is used to construct a connection string that is based on user-input in a safe way, that helps protect the application from connection-string-injection attacks.</p>
          </td>
        </tr><tr>
          <td>
            <p>Connect-to-database dialog box</p>
          </td>
          <td>
            <p>The new SqlDataSourceEnumerator class is used to obtain the list of the instances of SQL Server that are available in the network.</p>
          </td>
        </tr><tr>
          <td>
            <p>Connect-to-database dialog box</p>
          </td>
          <td>
            <p>The new database schema access API is used to retrieve the list of available databases from a connection.</p>
          </td>
        </tr></table>
    </content></div><h1 class="heading">Prerequisites</h1><div id="sectionSection3" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">Before running this sample, make sure that the following software is installed:</p>
      <ul xmlns=""><li>
          
            SQL Server or SQL Server Express. You can obtain SQL Server Express free of charge from the SQL Server Express <a href="http://go.microsoft.com/fwlink/?LinkId=31046" alt=""><linkText xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">Documentation and Samples Web site</linkText></a>. <br></br>
        </li><li>
          The SQL Server Database Engine samples. These samples are included with SQL Server. You can download the latest version of the samples at the SQL Server <a href="http://go.microsoft.com/fwlink/?linkid=62796" alt=""><linkText xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">Developer Web site</linkText></a>.<br></br>
        </li><li>
          
            .NET Framework SDK 2.0 or Microsoft Visual Studio 2005. You can obtain .NET Framework SDK free of charge. See <b>Installing the .NET Framework SDK</b>.<br></br>
        </li></ul>
    </content></div><h1 class="heading">Building the Sample</h1><div id="sectionSection4" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">If you have not already created the strong-name key file <b>SampleKey.snk</b> generate the key file by using the following instructions. </p>
      <h4 class="procedureHeading" xmlns="">To generate a strong name key file</h4><div id="procedureSectionEFBLBHA" class="section" xmlns=""><ol><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Open a Microsoft Visual Studio 2005 command prompt. Click <b>Start</b>, point to <b>All Programs</b>, point to <b>Microsoft Visual Studio 2005</b>, point to <b>Visual Studio Tools</b>, and then click <b>Visual Studio 2005 Command Prompt</b>.</p>
              <p xmlns="">—Or—</p>
              <p xmlns="">Open a Microsoft .NET Framework command prompt. Click <b>Start</b>, point to <b>All Programs</b>, point to <b>Microsoft .NET Framework SDK 2.0</b>, and then click <b>SDK Command Prompt</b>.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">At the command prompt, use the change directory (CD) command to change the current folder of the Command Prompt window to the Samples folder. </p>
              <div class="alert" xmlns=""><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note: </th></tr><tr><td>
                To determine the folder where samples are located, click <b>Start</b>, point to <b>All Programs</b>, point to <b>Microsoft SQL Server 2005</b>, point to <b>Documentation and Tutorials</b>, and then click <b>Samples Directory</b>. If the default installation location was used, the samples are located in &lt;<i>system_drive</i>&gt;:\Program Files\Microsoft SQL Server\90\Samples.<p></p>
              </td></tr></table><p></p></div>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">At the command prompt, run the following command to generate the key file:</p>
              <p xmlns="">
                <code>sn -k SampleKey.snk</code>
                <b> </b>
              </p>
              <div class="alert" xmlns=""><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Important: </th></tr><tr><td>
                For more information about the strong-name key pair, see "Security Briefs: Strong Names and Security in the .NET Framework" in the .NET Development Center on MSDN.<p></p>
              </td></tr></table><p></p></div>
            </content>
          </li></ol></div>
      <p xmlns="">To build the sample, do the following:</p>
      <h4 class="procedureHeading" xmlns="">To build the sample</h4><div id="procedureSectionEBBLBHA" class="section" xmlns=""><ol><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Compile the sample by using Visual Studio 2005 and the provided Visual Studio solution or by using Microsoft MSBuild, which is included in the .NET Framework SDK 2.0. Run a command similar to the following at the command prompt:</p>
              <p xmlns="">
                <code>msbuild /nologo /verbosity:quiet /property:Configuration=Debug CS\db3d.sln</code>
              </p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">If you did not install the SQL Server Database Engine samples in the default location, modify the path in the CREATE ASSEMBLY part of the script in Scripts\InstallCS.sql to refer to location where the samples were installed.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">If you are not an administrator for the SQL Server instance you are using, you must have an administrator grant you <b>CreateAssembly</b> permission to complete the installation.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Open the scripts\installCS.sql in SQL Server Management Studio. Run the script that is contained in the file, or run a command similar to the following at the command prompt:</p>
              <p xmlns="">
                <code>sqlcmd -E -I -i Scripts\InstallCS.sql</code>
              </p>
              <p xmlns="">This script performs the following actions: </p>
              <ul xmlns=""><li>
                  Drops the old db3d database if it exists.<br></br>
                </li><li>
                  Registers the db3dsql assembly.<br></br>
                </li><li>
                  Registers some CLR UDTs and an aggregate.<br></br>
                </li></ul>
            </content>
          </li></ol></div>
    </content></div><h1 class="heading">Running the Sample</h1><div id="sectionSection5" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">To run the sample, do the following:</p>
      <h4 class="procedureHeading" xmlns="">Step 1: Loading models from files</h4><div id="procedureSectionELBJBHA" class="section" xmlns=""><ul><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">The first time to run the application, it will not have any models or "wireframes" in the database. You must load them from files. The "models" subdirectory contains several model files you can use. </p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Click <b>File</b>, click <b>Open</b> and select one of the models from the "models" subdirectory. The model will display in the screen, and you can use the X, Y and Z sliders to rotate the model. You can see the user-defined types being used in the client to represent triangle information and to perform the transformations in the Triangle.cs and Point3D.cs files in the db3dsql project.</p>
            </content>
          </li></ul></div>
      <h4 class="procedureHeading" xmlns="">Step 2: Connecting to a database</h4><div id="procedureSectionEJBJBHA" class="section" xmlns=""><ul><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">To connect to a database, click <b>Database</b> and then click <b>Connect</b>. A dialog box will pop up where you can enter the name of the server, the database and authentication information. You should specify db3d as the name of the database to use.  Once you are done click <b>OK</b> to connect. You can see how to build a connection string that is based on user input in the see the connectToolStripMenuItem_Click method in the MainFrm.cs file in the db3dwin project.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">If you want, you can use the server and the database combo-boxes to browse the available servers and databases. You can see how to obtain the list of servers and/or databases in the file ConnectDlg.cs in the db3dwin project.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">NOTE: the list of servers will include only those servers in the network that are currently available and that have been specifically enabled for discoverability.</p>
            </content>
          </li></ul></div>
      <h4 class="procedureHeading" xmlns="">Step 3: Uploading a model to the database</h4><div id="procedureSectionEHBJBHA" class="section" xmlns=""><ul><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Once connected, you can upload a model</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">With a model loaded from a file from step 1, and after you connect to the database as described in step 2, click <b>Database</b> and then click <b>Copy wireframe</b>. This will prompt for a name and upload the triangle information to the database. You can also decide whether to enable "fast upload" using bulk-copy. You can experiment with the difference between doing many inserts one by one and using SqlBulkCopy for it. See the WireframeDbStorage.cs file in the db3dlib project.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">You can repeat this operation with several other models (or even several copies of the same one with different names), so that you have a database that has many models in it.</p>
            </content>
          </li></ul></div>
      <h4 class="procedureHeading" xmlns="">Step 4: Viewing more model information</h4><div id="procedureSectionEFBJBHA" class="section" xmlns=""><ul><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">The application has a second tab that lets you see a list of all the wireframes in the database. You can also see the number of triangles they are made of and the total surface of the model. The interesting thing about this is that the surface is computed in the server without having to ship the data to the client by using a user-defined aggregate. You can see the user-defined aggregate implementation in the surface.cs file in the db3dsql project. Also see step 6 for information about how to use it in Transact-SQL.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">To see this information, click the <b>Wireframe Information</b> tab.</p>
            </content>
          </li></ul></div>
      <h4 class="procedureHeading" xmlns="">Step 5: Rotating a model using Transact-SQL</h4><div id="procedureSectionEDBJBHA" class="section" xmlns=""><ul><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">When you use the slider controls in the client to rotate a wireframe, the application calls the "rotate" methods in each of the triangle objects that make up the model. Because these methods are part of the user-defined type that is registered in SQL Server, they can be used directly in the server.</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Let's say that you can to rotate a model a fixed angle and store it rotated. Instead of bringing the data to the client, applying the transform, and then sending it back to the server, you can do this with a single T-SQL statement. To see this in action follow these steps:</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Run the db3bwin application so that you can see the models. Connect to the database and select one model; for example, "tiger" (tiger.raw is the file that contains it if you did not upload it already).</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Press F5 to refresh, and you will see that the tiger is looking towards you</p>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Connect to the DB3D database using SQL Server Management Studio or some other query tool (for example, sqlcmd). Execute the following query:</p>
              <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>UPDATE Triangle SET TriangleObj.RotateY(0.6)FROM Triangle t INNER JOIN Wireframe w ON t.WireframeID = w.WireframeID WHERE w.WireframeName = 'tiger'</pre></td></tr></table></span></div>
            </content>
          </li><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Now go back to the application and press F5. You will see that, when the tiger is reloaded from the database, it will appear rotated in the Y axis.</p>
            </content>
          </li></ul></div>
      <h4 class="procedureHeading" xmlns="">Step 6: Computing the surface of a model using T-SQL</h4><div id="procedureSectionEBBJBHA" class="section" xmlns=""><ul><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">The grid in the "Wireframe Information" shows the total surface of a given wireframe. This is done using the "Surface" custom aggregate that aggregates Triangle objects into a scalar value that represents the sum of the areas of all the triangles that matched the criteria of the query. You can use the custom aggregate in Transact-SQL directly. For example, you can execute this query in SQL Server Management Studio or some other query tool (for example, sqlcmd):</p>
              <div class="code" xmlns=""><span codeLanguage="other"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left"></th></tr><tr><td colspan="2"><pre>CREATE PROCEDURE ListWireframesDetailed AS    SELECT w.WireframeID, WireframeName, COUNT(*) AS TriangleCount,           dbo.Surface(t.TriangleObj) AS Surface    FROM Wireframe w    INNER JOIN Triangle t ON w.WireframeID = t.WireframeID    GROUP BY w.WireframeID, WireframeName</pre></td></tr></table></span></div>
            </content>
          </li></ul></div>
    </content></div><h1 class="heading">Removing the Sample</h1><div id="sectionSection6" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">Use the following procedure to remove the sample:</p>
      <h4 class="procedureHeading" xmlns="">To remove the sample</h4><div id="procedureSectionEBBHBHA" class="section" xmlns=""><ol><li>
            <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
              <p xmlns="">Load and run Scripts\cleanup.sql in Management Studio. Or, run the following command at the command prompt:</p>
              <p xmlns="">
                <code>sqlcmd -E -I -i Scripts\cleanup.sql</code>
              </p>
            </content>
          </li></ol></div>
    </content></div><h1 class="heading">Comments</h1><div id="sectionSection7" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">The CLR for SQL Server or SQL Server Express must be enabled for this sample to work correctly.</p>
    </content><sections xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <h3 class="subHeading" xmlns="">Error message during deployment</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">When running the application from Visual Studio 2005, you might get an error that says that there was an error during deployment. Because you already created the database with all its elements by executing the createdb.sql script, you do not have to worry about that. It is. ok to say "ok to continue". If later, you change the db3dsql assembly, you will have to re-deploy it to SQL Server by using the script (or part of the script if you do not want to lose the existing model data).</p>
        </content></div>
      <h3 class="subHeading" xmlns="">About the graphics rendering code</h3><div class="subSection" xmlns=""><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <p xmlns="">This example is designed specifically to illustrate usage of various new features in SQL Server and Visual Studio 2005. It is not the goal of the example to provide a real 3-D visualization tool. To avoid unnecessary complexity in the example, the code that renders 3-D models in the screen is very simplistic and does not not perform common optimizations such as double-buffering nor does it do appropriate adjustments such as perspective correction. </p>
          <p xmlns="">
            Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications and assemblies should not be connected to or used with your production SQL Server database or your report server without the permission of the system administrator.
          </p>
        </content></div>
    </sections></div><h1 class="heading">Change History</span></h1><div id="sectionSection8" class="section"><content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
    </content></div><!--[if gte IE 5]>
			<tool:tip element="seeAlsoToolTip" avoidmouse="false"/><tool:tip element="languageFilterToolTip" avoidmouse="false"/><tool:tip element="roleInfoSpan" avoidmouse="false"/>
		<![endif]--></div>
      <div id="footer">
        
			
			© 2007 Microsoft Corporation. All rights reserved.
		</a>
 	
      </div>
    </div>
  </body>
</html>